﻿using System;
using System.Windows.Forms;
using Infrastructure;
using Presentation;

namespace WinClient
{
    public partial class LeftSideHeapForm : Form, IView
    {
        public LeftSideHeapForm()
        {
            InitializeComponent();
        }

        public string Key
        {
            get
            {
                return TextBoxKey.Text;
            }
            set
            {
                TextBoxKey.Text = value;
            }
        }

        public string Value
        {
            get
            {
                return TextBoxValue.Text;
            }
            set
            {
                TextBoxValue.Text = value;
            }
        }

        public string Status
        {
            get
            {
                return ErrorLabel.Text;
            }
            set
            {
                ErrorLabel.Text = value;
            }
        }

        public string MinValue
        {
            get
            {
                return TextBoxMin.Text;
            }
            set
            {
                TextBoxMin.Text = value;
            }
        }

        public string Log
        {
            get
            {
                return TextBoxLog.Text;
            }
            set
            {
                TextBoxLog.Text = value;
            }
        }

        public event Action OnInsert;
        public event Action OnGetMin;
        public event Action OnDeleteMin;
        public event Action OnDataChanged;

        private void ButtonInsert_Click(object sender, EventArgs e)
        {
            OnInsert();
        }

        private void ButtonGetMin_Click(object sender, EventArgs e)
        {
            OnGetMin();
        }

        private void ButtonDeleteMin_Click(object sender, EventArgs e)
        {
            OnDeleteMin();
        }

        private new void TextChanged(object sender, EventArgs e)
        {
            OnDataChanged();
        }

        private void RadioHtmlLog_CheckedChanged(object sender, EventArgs e)
        {
            if (RadioHtmlLog.Checked)
            {
                Program.SetLogger(new HtmlLogger());
            }
        }

        private void RadioTxtLog_CheckedChanged(object sender, EventArgs e)
        {
            if (RadioTxtLog.Checked)
            {
                Program.SetLogger(new TxtLogger());
            }
        }
    }
}
